function w = weightsLinear(d)

       global n xbar X sig2 SigmaB1inv SigmaB0inv 
       
       weights=zeros(n,1);
       
       X1=X(logical(d),:);
       X0=X(logical(1-d),:);
       weights(logical(d),:) = xbar * ((X1'*X1 + sig2*SigmaB1inv) \ X1');
       weights(logical(1-d),:) = - xbar * ((X1'*X1 + sig2*SigmaB0inv) \ X0');
       
       
       w = weights;

            
return
